<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<div class="ibox ">
	<div class="ibox-title" style="border-color: #fff;padding: 2px 90px 15px 15px;">
		<h4>物料列表</h4>
	</div>
	<div class="ibox-content border-bottom" style="padding-bottom: 0;">
		<div class="table-responsive">
			<table class="table table-striped table-hover table-bordered border-top">
				<thead>
					<tr>
						<th></th>
						<th width="5%">序号</th>
						<th>物料编码</th>
						<th>品牌</th>
						<th>物资名称</th>
						<th>型号</th>
						<th>类目</th>
						<th>单位</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${requestScope.list}" var="data" varStatus="index">
						<tr>
							<td><input style="width:20px;" type="checkbox" class="i-checks" onclick="checkSelected(${index.count})"></td>
							<td>${index.count}</td>
							<td id="materialId${index.count}" style="display: none">${data.materialId}</td>
							<td id="materialCode${index.count}">${data.materialCode}</td>
							<td id="materialBrand${index.count}">${data.brand}</td>
							<td id="materialName${index.count}">${data.materialName}</td>
							<td id="materialModel${index.count}">${data.standard}</td>
							<td id="materialCategory${index.count}">${data.categoryDesc}</td>
							<td id="materialUnit${index.count}">${requestScope.unitMap[data.materialUnit]}</td>
						</tr>
					</c:forEach>
				</tbody>
				<tfoot>
					<jsp:include page="../common/pages.jsp"></jsp:include>
				</tfoot>
			</table>
		</div>
	</div>
</div>
<script>

	var selected = [];

	// 添加/移除选中数据
	function checkSelected(id) {
		let index = selected.indexOf(id);
		if (index != -1) {
			selected.splice(index, 1);
		} else {
			selected.push(id);
		}
	}

    function gotoPage(page){
        var pageNumber = ${requestScope.pages.pageNumber};
        var currentPage = ${requestScope.pages.page};
        //首页和尾页无需跳转
        if((currentPage==1&&page==1)||(currentPage==pageNumber&&page==pageNumber)){

        } else {
            getRelateListAjax(selectedNodeId,page);
        }
    }
</script>
